#include<iostream>
using namespace std;
#include<cmath>

#include"library.h"

int main(){

	int i,j,n=3;
	double B[3][4] = {{1,1,1,3},{1,2,2,5},{1,3,4,8}};
	double **A = new double * [n];
	for(i=0;i<n;i++){
		A[i] = new double [n];
		for(j=0;j<n;j++){
			A[i][j] = B[i][j];
		}
	}
	double *b = new double [n];
	for(j=0;j<n;j++) b[j] = B[j][n];

	int *pivot = new int [n];
	int sign;

	ludcmp_Chinese(n,A,pivot,sign);
	cout<<"pivot:"; for(i=0;i<n;i++)cout<<pivot[i]<<","; cout<<endl;
	cout<<"sign="<<sign<<endl;
	ludcmp_solve_Chinese(n,A,pivot,b);

	cout<<"LU Decomposition: x=";
	for(i=0;i<n;i++)
		cout<<b[i]<<",";
	cout<<endl;

	delete [] pivot;
	delete [] b;
	for(i=0;i<n;i++) delete [] A[i];
	delete [] A;
	return 0;
}
